<template>
	<view class="wrap">
		<u-empty v-if="!arr || !arr.length" mode="list" text="暂无携行用户"
			icon="http://cdn.uviewui.com/uview/empty/list.png">
		</u-empty>
		<view class="ul" v-else>
			<view class="li" @click="goHerf(item.user_id)" v-for="item in arr">
				<view class="li-left">
					<image :src="item.avatar_url?item.avatar_url:avatar_default"></image>
				</view>
				<view class="li-right">
					<view class="box">
						<view class="title">昵称：</view>
						<view class="txt">{{item.nick_name}}</view>
					</view>
					<view class="box">
						<view class="title">年龄：</view>
						<view class="txt">{{item.age}}</view>
					</view>
					<view class="box">
						<view class="title">性别：</view>
						<view class="txt">{{item.gender==1?'男':'女'}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="btn-wrap">
			<u-button class="add-btn" type="primary" icon="plus-circle" text="创建携行用户"
				@click="goCarryUserRegister"></u-button>
		</view>
	</view>
</template>

<script>
	import {
		request,
		requestData
	} from '@/utils/http.js';
	export default {
		data() {
			return {
				arr: [],
				avatar_default: require('@/static/img/default-pic.png'),
			}
		},
		onShow() {
			this.initList()
		},
		methods: {
			//初始list
			initList() {
				request('/user/carried/list', {
					with_health: 1
				}).then(res => {
					this.arr = res?.datas?.users;
				}).catch(err => {
					console.log(err)
				})
			},

			goHerf(id) {
				uni.navigateTo({
					url: '/pagesC/carryUserDetail/carryUserDetail?id=' + id,
				})
			},
			goCarryUserRegister() {
				uni.navigateTo({
					url: '/pagesC/carryUserRegister/carryUserRegister',
				})
			},

		},
	}
</script>

<style lang="scss" scoped>
	.wrap {
		width: 100%;
		height: 100vh;
		box-sizing: border-box;
		background: #f3f3f7;
		font-size: 32rpx;
	}

	.ul {
		margin: 0;
		padding: 0;
		display: flex;
		flex-flow: column;
		justify-content: flex-start;
		align-items: center;

		.li {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 260rpx;
			line-height: 260rpx;
			background: #fff;
			margin: 10rpx 0;
			padding: 0 20rpx;
			width: 96%;
			border-radius: 30rpx;
			box-sizing: border-box;

			.li-left {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				width: 30%;

				// .txt {
				// 	margin-left: 15rpx;
				// 	font-size: 28rpx;
				// }
				image {
					width: 180rpx;
					height: 180rpx;
				}
			}

			.li-right {
				height: 100%;
				flex: 1;
				padding-left: 60rpx;
				box-sizing: border-box;
				display: flex;
				flex-flow: column;
				justify-content: center;
				align-items: flex-start;
				font-size: 28rpx;

				.box {
					height: 25%;
					line-height: 1;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					font-size: 32rpx;

					.title {}

					.txt {
						margin-left: 15rpx;
					}
				}
			}
		}
	}

	.btn-wrap {
		padding: 80rpx;

		/deep/ .u-button--primary {
			border: none !important;
			background: linear-gradient(to right, #d5ad57, #cfb58a);
		}
	}

	.add-btn {
		border: none;
		width: 60%;
		height: 80rpx;
		line-height: 80rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: $global-color-golden;
		border-radius: 40rpx;
		color: #fff;
		font-size: 32rpx;
		font-weight: 400;
	}
</style>